package top.kpromise.note.modules.todo.impl;

import org.springframework.stereotype.Service;
import top.kpromise.common.base.BaseServiceImpl;
import top.kpromise.note.modules.todo.entity.ToDoEntity;
import top.kpromise.note.modules.todo.mapper.jpa.ToDoRepository;
import top.kpromise.note.modules.todo.model.CreateToDo;
import top.kpromise.note.modules.todo.service.ToDoService;

@Service
public class ToDoServiceImpl extends BaseServiceImpl<ToDoEntity, ToDoRepository> implements ToDoService {

    protected ToDoServiceImpl(ToDoRepository repository) {
        super(repository);
    }

    @Override
    public void saveToDo(CreateToDo createToDo) {
        createToDo.parseData();
        ToDoEntity entity = new ToDoEntity();
        entity.setTitle(createToDo.getTitle());
        entity.setContent(createToDo.getContent());
        entity.setDeadline(createToDo.getDeadline());
        entity.setUserId(createToDo.getUserId());
        entity.setPriority(createToDo.getPriority());
        entity.setOrderNum(createToDo.getOrderNum());
        save(entity);
    }
}
